<?
class VS{
	public static $vars = array();
	
	public static function set($key, $val){
		$GLOBALS['__'.$key] = $val;								// 同步更新全局变量
		if(!isset(self::$vars[$key])){
			self::$vars[$key] = & $GLOBALS['__'.$key];
		}
	}
	
	public static function & get($key){
		if(isset(self::$vars[$key])){
			return self::$vars[$key];
		}else{
			if(isset($GLOBALS['__'.$key])){
				return $GLOBALS['__'.$key];
			}
		}
		return $GLOBALS['null'];
	}
	
	public static function update($array, $skey = ''){
		if($skey != ''){
			$GLOBALS['__'.$skey] = $array;						// 同步更新全局变量
			if(!isset(self::$vars[$skey])){
				self::$vars[$skey] = & $GLOBALS['__'.$skey];
			}
		}else{
			foreach($array as $key => $val){
				$GLOBALS['__'.$key] = $val;						// 同步更新全局变量
				self::$vars[$key] = & $GLOBALS['__'.$key];
			}
		}
	}
	
	public function & gets(){
		return self::$vars;
	}	
}
?>